//
//  ViewController.m
//  代码实现Storyboard自动布局
//
//  Created by apple on 15/9/15.
//  Copyright (c) 2015年 戴维营. All rights reserved.
//

#import "ViewController.h"
#import "Masonry.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIView *redView = [[UIView alloc] init];
    
    redView.backgroundColor = [UIColor redColor];
    
    [self.view addSubview:redView];
    
    [redView mas_makeConstraints:^(MASConstraintMaker *make)
    {
        //离上50个像素－－－》y ＝ 50；
        
        make.top.equalTo(@(50));
        
        //离左边50个像素－－－》x ＝ 120；
        make.left.equalTo(@(120));
        
        //面积
        make.size.equalTo(MASBoxValue(CGSizeMake(100, 100)));
    }];
    
    UIView *greenView = [[UIView alloc] init];
    
    greenView.backgroundColor = [UIColor greenColor];
    
    [self.view addSubview:greenView];
    
    [greenView mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.left.equalTo(redView.mas_right).offset(10);
        
        make.top.equalTo(redView.mas_top).offset(20);
        
        make.width.equalTo(redView.mas_width);
        
        make.height.equalTo(redView.mas_height);
        
    }];
    
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
